
Page({
    data: {
        y_phb_list: [],
        y_phb_listLimit: 0,
        base: 10,
    },
    onLoad: function (options) {
        this.yys_artlist();
    },
    //获取文章的资料
    yys_artlist() {
        var timestamp = Date.parse(new Date());
        var that = this;
        //链接远程服务器
        swan.request({
            url: 'https://api.cndzys.com/index.php/yys_wendalist', 
            method: 'GET',
            data: { num: that.data.y_phb_listLimit },
            header: { 'content-type': 'application/json' },
            success: function (res) {
                that.setData({ key_word_array: res.data.key_word_array,})
                var y_phb_arr = that.data.y_phb_list.concat(res.data.wenda_data)
                console.log(res.data.wenda_data.length);
                if (res.data.wenda_data.length > 10) { that.setData({ error: 1 }) }
                console.log(y_phb_arr);
                that.setData({ y_phb_list: y_phb_arr})
            },
        });
    },
    onReachBottom: function () {
        console.log("我滑动到底部了");
        this.setData({
          requestStatus: true,
          y_phb_listLimit: this.data.y_phb_listLimit + this.data.base
        })
        this.yys_artlist();
    },





    qandadetail(event) {
        var wenda_id = event.currentTarget.id
        swan.navigateTo({ url:'../qandadetail/qandadetail?wenda_id=' + wenda_id  });
    },
    search(event) {
        var info = event.currentTarget.id
        swan.navigateTo({ url:'../search/search?title='+info+'&type=wenda'});
    }
});
